package com.example.hal.model;

import java.util.List;

import org.restlet.resource.ClientResource;

import android.util.Log;

import com.example.hal.model.Evenement;

public class EvenementController{
	
	
	
	

	 public final ClientResource cr = new ClientResource(
	 EngineConfiguration.gae_path + "/rest/evenement");

	 public EvenementController() {
	 EngineConfiguration.getInstance();
	 }

	 public void create(Evenement evenement) throws Exception {
	 final EvenementControllerInterface uci = cr
	 .wrap(EvenementControllerInterface.class);

	 try {
	 uci.create(evenement);
	 Log.i("EvenementController", "Creation success !");
	 } catch (Exception e) {
	 Log.i("EvenementController", "Creation failed ! "+e.getMessage());
	 throw e;
	 }
	 }

	 public List<Evenement> getAllEvenement() throws Exception {
	 final EvenementControllerInterface uci = cr
	 .wrap(EvenementControllerInterface.class);
	 EvenementContainer content;
	 try{

		 content = uci.getAllEvenements();
		 Log.i("EvenementController", "getAllEvenements success !");
	 }catch (Exception e) {
		 Log.i("EvenementController", "getAllEvenements failed ! "+e.getMessage());
		 throw e;
		 }
	 return content.getEvenement_list();
	 }
	 
	 
	
	
}
